<?php

namespace Cck\ArticlesSystem\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class PermissionUpdateRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {

        $id = $this->route('permission')->id;

        return [
            'display_name' => [
                'required',
                'max:30'
            ],
            'name' => [
                'required',
                'max:30',
                Rule::unique('permissions', 'name')->ignore($id)
            ],
            'description' => 'max:255'
        ];
    }
}
